import 'dart:convert';

class Reply {
  var code = -4;
  var msg;
  var data;

  Reply();

  Reply.fromJson(Map<String, dynamic> jsonMap) {
    code = jsonMap['code'];
    msg = jsonMap['msg'];
    data = jsonMap['data'];
  }

  @override
  String toString() {
    return '{code: $code, msg: $msg, data: $data}';
  }
}

class User {
  int uid = 0;
  String name;
  String head;
  int lastTime = 0;
  String token;
  int status = 0;
  String about;

  User();

  User.fromJson(Map<String, dynamic> jsonMap) {
    uid = jsonMap['uid'];
    name = jsonMap['name'];
    head = jsonMap['head'];
    lastTime = jsonMap['lastTime'];
    token = jsonMap['token'];
    status = jsonMap['status'];
    about = jsonMap['about'];
  }

  @override
  String toString() {
    return 'User{uid: $uid, name: $name, head: $head, lastTime: $lastTime, token: $token, status: $status, about: $about}';
  }
}

class ReplyNoteList {
  List<ReplyNote> data = new List<ReplyNote>();

  ReplyNoteList(this.data);

  ReplyNoteList.fromJson(String list) {
    var dataList = json.decode(list) as List;
    //方法一:
    data.clear();
    for (Map<String, dynamic> index in dataList) {
      data.add(ReplyNote.fromJson(index));
    }
    //方法二:
    /*data = dataList.map((i) => ReplyNote.fromJson(i)).toList();*/
    print("data == " + data.toString());
  }

  @override
  String toString() {
    return 'ReplyNoteList{data: $data}';
  }
}

class ReplyNote {
  int nid = 0;
  String pic;
  String content;
  int nTime = 0;
  ReplyBook book;
  ReplyUser user;

  ReplyNote();

  ReplyNote.fromJson(Map<String, dynamic> jsonMap) {
    nid = jsonMap['nid'];
    pic = jsonMap['pic'];
    content = jsonMap['content'];
    nTime = jsonMap['nTime'];
    book = ReplyBook.fromJson(jsonMap['book']);
    user = ReplyUser.fromJson(jsonMap['user']);
  }

  @override
  String toString() {
    return 'ReplyNote{nid: $nid, pic: $pic, content: $content, nTime: $nTime, book: $book, user: $user}';
  }
}

class ReplyBook {
  int bid = 0;
  String title;

  ReplyBook.fromJson(Map<String, dynamic> jsonMap) {
    if (jsonMap != null) {
      bid = jsonMap['bid'];
      title = jsonMap['title'];
    }
  }

  @override
  String toString() {
    return 'ReplyBook{bid: $bid, title: $title}';
  }
}

class ReplyUser {
  int uid = 0;
  String name;
  String head;

  ReplyUser(this.uid, this.name, this.head);

  ReplyUser.fromJson(Map<String, dynamic> jsonMap) {
    if (jsonMap != null) {
      uid = jsonMap['uid'];
      name = jsonMap['name'];
      head = jsonMap['head'];
    }
  }

  @override
  String toString() {
    return 'ReplyUser{uid: $uid, name: $name, head: $head}';
  }
}

class BookList {
  List<Book> data;

  BookList(this.data);

  BookList.fromJson(String list) {
    var dataList = json.decode(list) as List;
    data = dataList.map((i) => Book.fromJson(i)).toList();
    print("data == " + data.toString());
  }

  @override
  String toString() {
    return 'BookList{data: $data}';
  }
}

class Book {
  int bid = 0;
  int uid = 0;
  String title;
  String pic;
  String msg;
  int bTime = 0;

  Book();

  Book.fromJson(Map<String, dynamic> jsonMap) {
    if (jsonMap != null) {
      bid = jsonMap['bid'];
      uid = jsonMap['uid'];
      title = jsonMap['title'];
      pic = jsonMap['pic'];
      msg = jsonMap['msg'];
      bTime = jsonMap['bTime'];
    }
  }

  @override
  String toString() {
    return 'Book{bid: $bid, uid: $uid, title: $title, pic: $pic, msg: $msg, bTime: $bTime}';
  }
}

class ReplyComment {
  int cid = 0;
  int nid = 0;
  String msg;
  int cTime = 0;
  ReplyUser user;

  ReplyComment();

  ReplyComment.fromJson(Map<String, dynamic> jsonMap) {
    if (jsonMap != null) {
      cid = jsonMap['cid'];
      nid = jsonMap['nid'];
      msg = jsonMap['msg'];
      cTime = jsonMap['cTime'];
      user = ReplyUser.fromJson(jsonMap['user']);
    }
  }

  @override
  String toString() {
    return 'ReplyComment{cid: $cid, nid: $nid, msg: $msg, cTime: $cTime, user: $user}';
  }
}

class ReplyCommentList {
  List<ReplyComment> data;

  ReplyCommentList(this.data);

  ReplyCommentList.fromJson(String list) {
    var dataList = json.decode(list) as List;
    data = dataList.map((i) => ReplyComment.fromJson(i)).toList();
    print("data == " + data.toString());
  }

  @override
  String toString() {
    return 'ReplyCommentList{data: $data}';
  }
}